<template>
  <div class="followMy">
    <!-- 列表 -->
    <sing-table :data="this.$data" :list="list" :selection="false">
    </sing-table>
  </div>
</template>

<script>
  import Mixin from '@/mixins/list'
  import columns from './columns/index'
  import apiCode from '@/api/apiConfig'

  export default {
    name: 'followMy',
    mixins: [Mixin],
    components: {},
    data () {
      return {
        columns // 列表字段
      }
    },
    created () {
      // 获取列表
      this.getList()
      // 监听列表刷新事件
      this.$on('global:followMyFresh', () => {
        this.getList()
      })
    },
    methods: {
    async getList () {
      this.loading = true
      let result = await this.$get(`api/user/followers`)
      this.loading = false
      if (result && result.code === apiCode.code.success) {
        this.list = result.data || []
      }
    },
    // 取消关注
    async cancelAttention (id) {
      const status = await this.$CONFIRM('取消关注？')
      if (status) {
        this.loading = true
        const result = await this.$DELETE(`api/user/following/${id}`)
        this.loading = false
        if (result && result.code === apiCode.code.success) {
          this.getList()
        }
      }
    }
  }
  }
</script>

<style lang="scss" scoped>
  .followMy {
    ::v-deep .el-table {
      .el-table__body-wrapper {
        height: calc(100vh - 200px);
      }
    }
  }
</style>
